<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>xscans</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="xscansmap.html" title="xscansmap" />
    <link rel="next" href="xscanu.html" title="xscanu" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">xscans</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="xscansmap.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="xscanu.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="xscans"></a>
      <div class="titlepage"></div>
      <a id="IndexXscans" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">xscans</span>
        </h2>
        <p>xscans — 
      Fast scanned synthesis waveform and the wavetable generator.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169038128"></a>
        <h2>Description</h2>
        <p>
      Experimental version of <a class="link" href="scans.html" title="scans"><em class="citetitle">scans</em></a>.  Allows much larger matrices and is faster and smaller but removes some (unused?) flexibility.  If liked, it will replace the older opcode as it is syntax compatible but extended.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169040496"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>xscans</strong></span> kamp, kfreq, ifntraj, id [, iorder]</pre>
      </div>
      <div class="refsect1">
        <a id="idp169107184"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifntraj</em></span> --  table containing the scanning trajectory. This is a series of numbers that contains addresses of masses. The order of these addresses is used as the scan path. It should not contain values greater than the number of masses, or negative numbers. See the <a class="link" href="SiggenScanTop.html" title="Scanned Synthesis"><em class="citetitle">introduction to the scanned synthesis section</em></a>.
    </p>
        <p>
      <span class="emphasis"><em>id</em></span> -- If positive, the ID of the opcode. This will be used to point the scanning opcode to the proper waveform maker. If this value is negative, the absolute of this value is the wavetable on which to write the waveshape. That wavetable can be used later from an other opcode to generate sound. The initial contents of this table will be destroyed.
    </p>
        <p>
      <span class="emphasis"><em>iorder</em></span> (optional, default=0) -- order of interpolation used internally. It can take any value in the range 1 to 4, and defaults to 4, which is quartic interpolation. The setting of 2 is quadratic and 1 is linear. The higher numbers are slower, but not necessarily better. 
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169112272"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kamp</em></span>  -- output amplitude. Note that the resulting amplitude is also dependent on instantaneous value in the wavetable. This number is effectively the scaling factor of the wavetable.
    </p>
        <p>
      <span class="emphasis"><em>kfreq</em></span> -- frequency of the scan rate
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169114928"></a>
        <h2>Matrix Format</h2>
        <p>
      The new matrix format is a list of connections, one per line linking point x to point y.   There is no weight given to the link; it is assumed to be unity.  The list is preceded by the line &lt;MATRIX&gt; and ends with a &lt;/MATRIX&gt; line
    </p>
        <p>
      For example, a circular string of 8 would be coded as

      </p>
        <div class="informalexample">
          <pre class="programlisting">
&lt;MATRIX&gt;
0 1
1 0
1 2
2 1
2 3
3 2
3 4
4 3
4 5
5 4
5 6
6 5
6 7
7 6
0 7
&lt;/MATRIX&gt;
        </pre>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169118144"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the xscans opcode. It uses the file <a class="ulink" href="examples/xscans.csd" target="_top"><em class="citetitle">xscans.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp169120000"></a>
          <p class="title">
            <strong>Example 1056. Example of the xscans opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
-odac    <span class="comment">;;;realtime audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o xscans.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 2
<span class="ohdr">0dbfs</span>  <span class="op">=</span> 1
<span class="comment">;the matrices can be found in /manual/examples</span>

<span class="oblock">instr</span> 1	<span class="comment">; Plain scanned syntnesis</span>

  a0       <span class="op">=</span>           0
           <span class="opc">xscanu</span>      1, .01, 6, 2, "128,8<span class="op">-</span>cylinderX", 4, 5, 2, .1, .1, <span class="op">-</span>.01, .1, .5, 0, 0, a0, 0, 0
  a1       <span class="opc">xscans</span>      .7, <span class="opc">cpspch</span>(p4), 7, 0, 1
           <span class="opc">outs</span>        a1, a1
<span class="oblock">endin</span>


<span class="oblock">instr</span> 2	<span class="comment">; Scan synthesis with audio injection and dual scan paths</span>
	<span class="comment">; tap the mic or sing to inject audio into the resonators</span>

  a0,aa    <span class="opc">ins</span>
  a0       <span class="op">=</span>           a0<span class="op">/</span>.8
           <span class="opc">xscanu</span>      1, .01, 6, 2, "128,8<span class="op">-</span>gridX", 14, 5, 2, .01, .05, <span class="op">-</span>.05, .1, .5, 0, 0, a0, 0, 0
  a1       <span class="opc">xscans</span>      .5, <span class="opc">cpspch</span>(7.00), 7, 0, 1
  a2       <span class="opc">xscans</span>      .5, <span class="opc">cpspch</span>(7.001), 77, 0, 1
           <span class="opc">outs</span>        a1<span class="op">+</span>a2,a1<span class="op">+</span>a2
<span class="oblock">endin</span> 


<span class="oblock">instr</span> 3	<span class="comment">; Vibrating structure with audio injection</span>
	<span class="comment">; Tap the MIC - to inject audio into the resonators</span>

  a0,aa    <span class="opc">ins</span>          
  a0       <span class="op">=</span>          a0<span class="op">/</span>.8
           <span class="opc">xscanu</span>     1, .01, 6, 2, "128<span class="op">-</span>stringcircularX", 14, 5, 2, .01, .05, <span class="op">-</span>.05, .25, .75, 0, 0, a0, 0, 1
<span class="oblock">endin</span>


<span class="oblock">instr</span> 4	<span class="comment">; Modulated scanners</span>

  i1       <span class="opc">bexprnd</span>     5
  i2       <span class="opc">bexprnd</span>     1
  ko       <span class="opc">oscil</span>       i1, i2, 9
  ka1      <span class="opc">oscili</span>      .5, .15<span class="op">*</span>8, p7
  ka2      <span class="opc">oscili</span>      .5, .15<span class="op">*</span>8, p8
  kf       <span class="opc">oscili</span>      1, .15, p4
  kf       <span class="op">=</span>           2^(kf<span class="op">/</span>12)<span class="op">*</span>p6<span class="op">*</span>440<span class="op">+</span>ko
  a1       <span class="opc">xscans</span>      p9<span class="op">*</span>ka1, kf<span class="op">+</span>i1, 777, 1, 1
  a2       <span class="opc">xscans</span>      p9<span class="op">*</span>ka2, (kf<span class="op">+</span>i1)<span class="op">*</span>2.1, 77, 1, 1
           <span class="opc">outs</span>        a1<span class="op">+</span>a2, a1<span class="op">+</span>a2
<span class="oblock">endin</span>

<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="comment">; Initial condition</span>
<span class="stamnt">f</span>1 0 128 7 0 64 1 64 0
<span class="comment">; Masses</span>
<span class="stamnt">f</span>2 0 128 -7 1 128 1
<span class="comment">; Centering force</span>
<span class="stamnt">f</span>4  0 128 -7 0 128 2
<span class="stamnt">f</span>14 0 128 -7 2 64 0 64 2
<span class="comment">; Damping</span>
<span class="stamnt">f</span>5 0 128 -7 1 128 1
<span class="comment">; Initial velocity</span>
<span class="stamnt">f</span>6 0 128 -7 -.0 128 .0
<span class="comment">; Trajectories</span>
<span class="stamnt">f</span>7 0 128 -5 .001 128 128
<span class="stamnt">f</span>777 0 128 -23 "128-stringcircular"
<span class="stamnt">f</span>77 0 128 -23 "128-spiral-8,16,128,2,1over2"
<span class="comment">; Sine</span>
<span class="stamnt">f</span>9 0 16384 10 1

<span class="comment">; Pitch tables</span>
<span class="stamnt">f</span>100 0 1024 -7 +3 128 +3 128 -2 128 -2 128 +0 128 +0 128 -4 128 -4 128 +3
<span class="stamnt">f</span>101 0 1024 -7 -2 128 -2 128 -2 128 -2 128 -5 128 -5 128 -4 128 -4 128 -2
<span class="stamnt">f</span>102 0 1024 -7 +3 128 +3 128 +2 128 +2 128 +0 128 +0 128 +0 128 +0 128 +3
<span class="stamnt">f</span>103 0 1024 -7 +7 128 +7 128 +5 128 +5 128 +3 128 +3 128 +3 128 +3 128 +7 

<span class="comment">; Amplitude tables</span>
<span class="stamnt">f</span>200 0 1024 7 1 128 0 128 0 127 0 1 1 128 0 128 0 127 0 1 1 128 0 127 0 1 1
<span class="stamnt">f</span>201 0 1024 7 0 127 0 1 1 127 0 1 1 128 0 127 0 1 1 127 0 1 1 128 0 127 0 1 1 127 0 1 1
<span class="stamnt">f</span>202 0 1024 7 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 1 127 0 1 
<span class="stamnt">f</span>203 0 1024 7 1 1024 0

<span class="comment">;----------------------------------</span>

<span class="comment">; Note list</span>
<span class="stamnt">i</span>1 0 10 6.00                                 
<span class="stamnt">s</span>
<span class="stamnt">i</span>2 1 10
<span class="stamnt">s</span>
<span class="stamnt">i</span>3 1 23
<span class="stamnt">i</span>4 1 23  101 1 .5  200 202 1.5
<span class="stamnt">i</span>4 . .   102 0 .5  200 201 1
<span class="stamnt">i</span>4 . .   103 0 .5  200 201 1 
<span class="stamnt">i</span>4 . .   100 0 .25 200 200 2
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      For similar examples, see the documentation on <a class="link" href="scans.html" title="scans"><em class="citetitle">scans</em></a>.
    </p>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169125632"></a>
        <h2>See Also</h2>
        <p>
More information on Scanned Synthesis (as well as several other matrices) is available on the <a class="ulink" href="http://www.csounds.com/scanned/" target="_top"><em class="citetitle">Scanned Synthesis page</em></a> at cSounds.com.
    </p>
        <p> Also an article on these opcodes: <a class="ulink" href="http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html" target="_top"><em class="citetitle">http://www.csounds.com/stevenyi/scanned/yi_scannedSynthesis.html</em></a>  , written by Steven Yi </p>
        <p>
      <a class="link" href="scans.html" title="scans"><em class="citetitle">scans</em></a>, 
      <a class="link" href="xscanu.html" title="xscanu"><em class="citetitle">xscanu</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp169131456"></a>
        <h2>Credits</h2>
        <p>Written by John ffitch.</p>
        <p>New in version 4.20</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="xscansmap.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="xscanu.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">xscansmap </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> xscanu</td>
        </tr>
      </table>
    </div>
  </body>
</html>
